package com.librelato.tela.datamodel;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.librelato.bean.SolicitacaoBean;

public class SolicitacaoDataModel extends ListDataModel<SolicitacaoBean>
		implements SelectableDataModel<SolicitacaoBean> {
	
	public SolicitacaoDataModel(List<SolicitacaoBean> data) {
		super(data);
	}

	@SuppressWarnings("unchecked")
	@Override
	public SolicitacaoBean getRowData(String linha) {
		List<SolicitacaoBean> listaSolicita = (List<SolicitacaoBean>) getWrappedData();
		for (SolicitacaoBean solicita : listaSolicita) {
			if ((solicita.getFilial() + solicita.getNumSolicitacao() + solicita
					.getItem()).equals(linha)) {
				return solicita;
			}
		}
		return null;
	}

	@Override
	public Object getRowKey(SolicitacaoBean linha) {
		return linha.getFilial()+linha.getNumSolicitacao()+linha.getItem();
	}

}
